﻿'*******************************************************************************************
'* Copyright Brügmann Software GmbH, Papenburg
'* Author: Björn Kremer
'* Contact: codeplex<at>patorg.de
'* 
'* VB.CMIS is a VB.NET implementation of the Content Management Interoperability Services (CMIS) standard
'*
'* This file is part of VB.CMIS.
'* 
'* VB.CMIS is free software: you can redistribute it and/or modify
'* it under the terms of the GNU Lesser General Public License as published by
'* the Free Software Foundation, either version 3 of the License, or
'* (at your option) any later version.
'* 
'* VB.CMIS is distributed in the hope that it will be useful,
'* but WITHOUT ANY WARRANTY; without even the implied warranty of
'* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'* GNU Lesser General Public License for more details.
'* 
'* You should have received a copy of the GNU Lesser General Public License
'* along with VB.CMIS. If not, see <http://www.gnu.org/licenses/>.
'*******************************************************************************************
Imports System.Xml.Serialization
Namespace Properties
   <XmlRoot("propertyDecimal", Namespace:=CmisNamespaceConstants.Cmis)>
   Public Class CmisPropertyDecimal
      Inherits CmisProperty(Of Decimal)
      Protected Overrides Function GetValueForSerialization() As List(Of String)
         Dim retVal As New List(Of String)
         If Values IsNot Nothing Then
            For Each val As Decimal In Values
               Dim tmpItem As String = val.ToString(Globalization.CultureInfo.InvariantCulture)
               If Not String.IsNullOrEmpty(tmpItem) Then
                  retVal.Add(tmpItem)
               End If
            Next
         End If
         Return retVal
      End Function

      Protected Overrides Sub SetSerializedValues(values As System.Collections.Generic.List(Of String))
         Dim tmpValues As New List(Of Decimal)
         For Each val As String In values
            If val IsNot Nothing Then
               tmpValues.Add(Decimal.Parse(val, Globalization.CultureInfo.InvariantCulture))
            End If
         Next
         Me.Values = tmpValues.ToArray
      End Sub


      Public Sub New(propertyDefinitionId As String, localName As String, displayName As String, queryName As String, values As Decimal())
         MyBase.New(propertyDefinitionId, localName, displayName, queryName, values)
      End Sub

      Public Sub New()
         MyBase.New()
      End Sub
   End Class
End Namespace